package com.peace.hospital.feign.drugstorage.controller;

import com.peace.hospital.entity.common.Druginformation;
import com.peace.hospital.entity.drugstorage.*;
import com.peace.hospital.feign.drugstorage.service.IDrugStorageService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/drugStorageController")
public class DrugstorageController {
    //添加药品信息
    @Autowired
    private IDrugStorageService iDrugStorageService;

    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @PostMapping("/addDrugInfo")

    public String addDrugInfo(Druginformation din, HttpServletRequest request){
        System.out.println("haha");

        return iDrugStorageService.addDrugInfo(din);
    }
    //查询药品信息
   @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @GetMapping("/findDrugInfo")
    public String findDrugInfo(Druginformation din) {
        System.out.println(din);
        return iDrugStorageService.findDrugInfo(din);
    }

    //修改药品信息
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @PostMapping("/alterDrugInfo")

    public String alterDrugInfo(Druginformation din) {

        return iDrugStorageService.alterDrugInfo(din);
    }

    //添加入库单
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @PostMapping("/addWaeInfo")
    public String addWaeInfo(DruginfoAndAnyDto druginfoAndAnyDto){
        System.out.println(druginfoAndAnyDto);

        return iDrugStorageService.addWaeInfo(druginfoAndAnyDto);
    }
    // 查询入库单
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @GetMapping("/findWaentry")
    public String findWaentry(Waentry waentry){
       return iDrugStorageService.findWaentry(waentry);

    }
    //查询入库的药品
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @GetMapping("/findDrugByWaeId")

    public String findDrugByWaeId(Waentry waentry){

        return iDrugStorageService.findDrugByWaeId(waentry);
    }

    // 插入报损单 和报损药品信息
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @PostMapping("/addDamage")
    public String addDamage( DruginfoAndAnyDto druginfoAndAnyDto){
        System.out.println(druginfoAndAnyDto);
        return iDrugStorageService.addDamage(druginfoAndAnyDto);
    }
    //查询报损单
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @GetMapping("/findFrmByfrmid")
    public String findFrmByFrmid(Frmloss frmloss){

        return iDrugStorageService.findFrmByFrmid(frmloss);
    }
    //查询报损药品
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @GetMapping("/findDamageByFrmid")
    public String findDamageByFrmid(Damagedrug damagedrug){

        return iDrugStorageService.findDamageByFrmid(damagedrug);
    }

    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @GetMapping("/test")
    public String test(){

        return iDrugStorageService.test();
    }

    //    添加出库信息
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @PostMapping("addOutWInfo")
    public String addOutWInfo(DruginfoAndAnyDto druginfoAndAnyDto){
        System.out.println(druginfoAndAnyDto);
        return iDrugStorageService.addOutWInfo(druginfoAndAnyDto);
    }
    //    查找出库单信息
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @GetMapping("findOutWa")
    public String findOutWa(Outwarehouse outwarehouse){
        return iDrugStorageService.findOutWa(outwarehouse);
    }

    //    出库单id查询出库药品
    @RequiresRoles(value = {"drugstorage","root"},logical = Logical.OR )
    @GetMapping("findOutDByOutid")
    public String findOutDByOutid(Outdrug outdrug){

        return iDrugStorageService.findOutDByOutid(outdrug);
    }
}
